/*
 * 文章信息管理模块
 * @Author: ljb
 * @Date: 2018-11-21 14:20:36
 * @Last Modified by: kanglin
 * @Last Modified time: 2019-01-22 17:26:26
 */

const article_detail = sessionStorage.getItem('article_detail') ? JSON.parse(sessionStorage.getItem('article_detail')) : {};

export default {
	namespaced: true,
	state: {
		article_detail,
	},
	mutations: {
		// 保存新闻详情
		setArticleDetail(state, article) {
			state.article_detail = article;

			sessionStorage.setItem('article_detail', JSON.stringify(article));
		},
	},
	actions: {
		// 保存新闻详情
		toSetArticleDetail({ commit }, article) {
			commit('setArticleDetail', article);

			return Promise.resolve();
		},
	},
	getters: {
		// 获取新闻详情
		getArticleDetail(state) {
			return state.article_detail || {};
		},
	},
};

